package com.hns.can.service.service;

import com.hns.can.service.vo.SafeBehaviourVo;
import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.service.BaseInfoValueService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 安全驾驶行为service
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Service
public class SafeBehaviourService extends CommonService {

	@Autowired
    private BaseInfoValueService baseInfoValueService;
	
    /**
     * 分页查询安全行为
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @Transactional
    public Pagination searchSafeBehaviour(CommonParamsVo vo) throws Exception {
        Pagination page = this.myBatisPage("safeBehaviour.getDriverBehaviourCount", "safeBehaviour.getDriverBehaviourGrade", vo,SafeBehaviourVo.class);
        List<Object> list = page.getData();
        baseInfoValueService.fillOrganLineDrvName(list);
        page.setData(list);
        return page;
    }

    /**
     * 导出安全行为数据
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @Transactional
    public List<SafeBehaviourVo> getAllSafeBehaviour(CommonParamsVo vo) throws Exception {
        List<SafeBehaviourVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("safeBehaviour.getDriverBehaviourGrade", vo), SafeBehaviourVo.class);
        baseInfoValueService.fillOrganLineDrvName(list);
        return list;
    }
}
